# Based on bira theme

setopt prompt_subst

() {

local PR_USER PR_USER_OP PR_PROMPT PR_HOST RANDOM_EMOJI

# Check the UID
if [[ $UID -ne 0 ]]; then # normal user
  PR_USER='%F{green}%n%f'
  PR_USER_OP='%F{green}%#%f'
  PR_PROMPT='%f➤ %f'
else # root
  PR_USER='%F{red}%n%f'
  PR_USER_OP='%F{red}%#%f'
  PR_PROMPT='%F{red}➤ %f'
fi

# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT"  ||  -n "$SSH2_CLIENT" ]]; then
  PR_HOST='%F{red}%M%f' # SSH
else
  PR_HOST='%F{green}%M%f' # no SSH
fi

EMOJI=(💩 🐜 🐠 🐦 🚀 🐞 🙈 🐭 👽 ☕️  🎁 🔬 💀 🐷 🐼 🙀 🐶 🐸 🐧 🐳 💾 🍪 🌞 🌍 🐌 🐓 🍄 👹 👺 👾 🔥 💥 🐛 💦 )


function real_random {
    echo `od -vAn -N1 -tu < /dev/urandom | tr -d ' '`
}
function random_emoji {
    echo -n "$EMOJI[$(real_random)%$#EMOJI+1]"
}
function random_color {
    echo -n "$FG[$(printf %03d $(real_random))]"
}

RANDOM_EMOJI='$(random_emoji) %f'

local return_code="%(?..%F{red}%? ↵%f)"
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
local current_dir="%B%F{blue}%~%f%b"
local git_branch='$(git_prompt_info)'
local apply_logo='$(random_color) %f'

PROMPT="╭─${user_host} ${RANDOM_EMOJI}❯ ${current_dir} \$(ruby_prompt_info) ${git_branch}
${apply_logo}
╰$PR_PROMPT"
RPROMPT="${return_code}"

ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}[Git:"
ZSH_THEME_GIT_PROMPT_SUFFIX="] %f"
ZSH_THEME_RUBY_PROMPT_PREFIX="%F{red}["
ZSH_THEME_RUBY_PROMPT_SUFFIX="]%f"

}
